﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class DangNhap : System.Web.UI.Page
{
    DataProvider duLieu = new DataProvider();

    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!string.IsNullOrEmpty((string)Session["Username"]) & (int)Session["Logged"] == 1)
            {
                Response.Redirect("Gio_Hang.aspx");
            }
            else
            {
                Login.Visible = true;
            }
        }
    }

    protected void dangnhap_Click(object sender, System.EventArgs e)
    {
        string Username = UserNamez.Text;
        string Password = Passwordz.Text;
        if (!string.IsNullOrEmpty(Username) & !string.IsNullOrEmpty(Password))
        {
            if (duLieu.Check_Login(Username, Password) == true)
            {
                Session["Username"] = Username;
                Session["Logged"] = 1;
                Response.Redirect("Gio_Hang.aspx");
            }
            else
            {
                dangnhapsai.Visible = true;
                Session["Username"] = "";
                Session["Logged"] = 0;
            }
        }
    }
}